/*
 * 易族智汇（北京）科技有限公司 版权所有。
 * 未经许可，您不得使用此文件。
 * 官方地址：www.javamall.com.cn
 */
package com.enation.app.javashop.core.client.fallback.system;

import com.enation.app.javashop.core.client.feignimpl.system.SensitiveWordsClientFeignImpl;
import com.enation.app.javashop.core.handler.BaseFallbackFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fk
 * @version v2.0
 * @Description: 敏感词断路器
 * @date 2018/9/27 14:11
 * @since v7.0.0
 */
@Component
public class SensitiveWordsClientFallbackFactory extends BaseFallbackFactory<SensitiveWordsClientFeignImpl> implements FallbackFactory {


    @Override
    protected SensitiveWordsClientFeignImpl fallback() {
        return new SensitiveWordsClientFallback();
    }

    /**
     * @author fk
     * @version v2.0
     * @Description: 敏感词断路器
     * @date 2018/9/27 14:11
     * @since v7.0.0
     */
    @Component
    public static class SensitiveWordsClientFallback implements SensitiveWordsClientFeignImpl {

        protected final Log logger = LogFactory.getLog(this.getClass());

        @Override
        public List<String> listWords() {

            this.logger.error("系统服务返回异常，获取敏感词异常");
            List<String> mockList = new ArrayList<>();
            mockList.add("this is mock");
            return mockList;
        }
    }
}
